﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace uam_fps_game.NetComponents
{
    public class ClientPlayerNetComp : NetComp
    {
        /// Since client network update will most probably be called less frequently than general game update, a queue of PlayerInputs in neccessary
        /// - they may be generated every frame, and all of them should be sent to server.
        /// Elements of the queue are provided by node using the component.
        /// In Update() method, all queued inputs are dequeued and sent to server.
        public Queue<PlayerInput> NewInputsToSend;

        /// Here, PlayerState most recently received from server is stored. This is the data that describes some player's node state on the server
        /// amd will be used by client to make client's world state consistent with server's.
        public PlayerState LastReceivedState;

        int _playerId;

        public ClientPlayerNetComp(int playerId)
        {
            _playerId = playerId;

            NewInputsToSend = new Queue<PlayerInput>();
            LastReceivedState = null;
        }

        internal override void Update(float deltaTime)
        {
            // foreach input in queue
            //  deque and send input to server (message per input, or all inputs in one message, or ...) - PLAYER_INPUT message
        }

        internal override void ProcessMessage()
        {
            // read PlayerState from the PLAYER_STATE message and save in _lastState field
        }
    }
}
